Predicting DXL Memory and CPU Usage

Has anyone had any success in predicting or profiling DXL applications for memory and CPU usage?

I have a script that opens, closes, and modifies modules, possibly hundreds or even thousands of modules. I want to know, or least have a rough idea, how many modules I can run through the script before running out of memory.

Cross posts:

http://smartdxl.com/forum/viewtopic.php?f=1&t=602

http://stackoverflow.com/questions/19422567/predicting-dxl-memory-and-cpu-usage


oaklodge - Thu Oct 17 05:12:23 EDT 2013

Re: Predicting DXL Memory and CPU Usage
kourosh - Thu Oct 17 12:51:16 EDT 2013

It's extremely difficult to predict such a thing because there are many factors specific to each module you must consider:

1. how big is the module / how much content exist in objects & attributes
2. is there RTF content in the module
3. has the module been baselined recently
4. is the module broken up into many sections
5. how many OLE objects and pictures are in the module
6. how many layout DXL columns are in the default view
7. how many DXL attributes are in the module
8. how many links are in the module

and so on...

You may want to restore your database in a test environment and run the script there on a smaller dataset first (assuming you have a hierarchy with folders/projects) while monitoring the memory usage of the doors.exe process. See how that goes and gradually increase the dataset size as it becomes possible.

Re: Predicting DXL Memory and CPU Usage
llandale - Thu Oct 17 14:14:02 EDT 2013

If you close modules that you open and often close residually opened modules, then it won't matter how many there are.  What would matter would be how much memory leak there is in your code, which primarily are:

  • Wasted string table space, usually due to string concatenation
  • Allocated units created but not deleted (such as Buffers)

-Louie

Re: Predicting DXL Memory and CPU Usage
Mathias Mamsch - Fri Oct 18 05:58:47 EDT 2013

Just my two cents: If you are running one script on a large set of modules, how about a parallelization framework? In python for example it is cool, using the multiprocessing library you can do something like this:

def doWork (item):
        # expensive work
        pass

with multiprocessing.pool(5) as pool:  # use 5 parallel processes
       result = pool.map(doWork, [ ... list of items ... ]

The multiprocessing library will take care about starting 5 processes, splitting up the list of items into parts, feeding it to the 5 processes, executing the function doWork on the items and sending the results back to the calling process. I figure something equal can be done in DXL. It will not only speed up your process (due to parallelization -> most operations seem to be CPU bound), but also get rid of memory issues, since you can use MORE memory even on DOORS 8 (because of parallel processes) and memory will get freed by the external processes after completion. You will however require a couple of licenses (at least one more than usual) on parallel processing, but I guess this is something most companies might be willing to take for the runtime of the scripts.

If you are interested in doing something like this together, msg me. However regarding your original question we implemented successfully to measure the DOORS memory allocation using an external tool from DXL and safely stopping the script at a configurable memory barrier. This might also a way to go. When it comes to actually predicting the memory usage, this is kind of unreliable. Depending on the size of data you will encounter next you will waste more or less memory, so you probably cannot say reliably, how many modules you will be able to execute without actually doing it ...

Just my two cents, regards, Mathias
 

Re: Predicting DXL Memory and CPU Usage
VinayN - Mon Oct 21 04:57:09 EDT 2013

Mathias Mamsch - Fri Oct 18 05:58:47 EDT 2013

Just my two cents: If you are running one script on a large set of modules, how about a parallelization framework? In python for example it is cool, using the multiprocessing library you can do something like this:

def doWork (item):
        # expensive work
        pass

with multiprocessing.pool(5) as pool:  # use 5 parallel processes
       result = pool.map(doWork, [ ... list of items ... ]

The multiprocessing library will take care about starting 5 processes, splitting up the list of items into parts, feeding it to the 5 processes, executing the function doWork on the items and sending the results back to the calling process. I figure something equal can be done in DXL. It will not only speed up your process (due to parallelization -> most operations seem to be CPU bound), but also get rid of memory issues, since you can use MORE memory even on DOORS 8 (because of parallel processes) and memory will get freed by the external processes after completion. You will however require a couple of licenses (at least one more than usual) on parallel processing, but I guess this is something most companies might be willing to take for the runtime of the scripts.

If you are interested in doing something like this together, msg me. However regarding your original question we implemented successfully to measure the DOORS memory allocation using an external tool from DXL and safely stopping the script at a configurable memory barrier. This might also a way to go. When it comes to actually predicting the memory usage, this is kind of unreliable. Depending on the size of data you will encounter next you will waste more or less memory, so you probably cannot say reliably, how many modules you will be able to execute without actually doing it ...

Just my two cents, regards, Mathias
 

Usage of memory management perms:

1) initNotDisplayedOpenModules()    -  This is 1st perm which records modules already opened before any operation begins and should be called at start of any looping operation.

2) DisplayMemoryWarning()   - 2nd perm which checks memory usage of application and closes modules opened in back end when application consumes more memory than the prescribed warning level and this should be placed inside a for or while loop so that memory is monitored in each iteration in regular interval.
3) closeNotDisplayedOpenedModules() - 3rd perm which does all cleanup operation at last and closees all modules opened in back end during end of any operation


Usage of these three perms is shown below in the example code and these 3 DXL perms should be used in combination and  when user is looping through all objects in a module with huge data or objects.


 /********************************************/

               Object o = current
               initNotDisplayedOpenModules()    // First perm which records modules opened before any operation
               Module m = current
               int i = 0
               for o in m do
               {
                   if (DisplayMemoryWarning())   //second perm which checks memory usage and closes                        //modules opened during any operation
                   {
                              break
                   }
                   i = o."Absolute Number"
                   gotoObject(i, m)
                   o = next o
               }   
               closeNotDisplayedOpenedModules() // Third perm which does all cleanup operation and tries to close //all modules which were opened during the operation


 /********************************************/


1) initNotDisplayedOpenModules()   is used before the start of the operation
2) DisplayMemoryWarning())   is used during actual operation i.e. with in for or while loop which monitors memory used by application.
3) closeNotDisplayedOpenedModules() is used at the end of the operation.


Rational DOORS DXL developer should use these 3 perms in any custom DXL code where it involves looping of all objects in a big module with huge data and links to other module. This should be used inside a loop which actually loops through all objects to collect data.

 

Customizing these new memory management perms:

 

Memory usage varies from system to system. Some system may have good memory and thus DOORS can use more memory for its operations. Since we cannot fix a value or generalize the maximum memory that can be used by Rational DOORS, we have given some registry values to customize it. This helps Rational DOORS DXL developer to set the system memory that DOORS can use.

 

Default values set in Rational DOORS:

By default there are certain parameters set and these can be overridden by registry entries set under DOORS client registry under config key. Below are the registry string keys with its importance and usage

 

MEM_LEVEL_CLOSE - Its default value is 1000 MB and upon reaching this level, the memory management perm will start closing opened modules that it keeps track of. Customer can override this max value by having a string key registry entry MEM_LEVEL_CLOSE under DOORS Client->Config and specify suitable value. Customer should know what is the maximum MB of memory that his system can allocate to DOORS and give that value under this registry key. For example if a machine can allocate 2 GB of memory to doors.exe without making it crash then value for this registry key would be 1800 or 2000. So they have to decide the value by trial and error method. Higher the value good performance but machine should have such high memory to allocate.


MEM_LEVEL_WARN - Its default value is 800 MB and upon reaching this level, the memory management perm will warn user to either continue or abort the operation to avoid crash. Customer can override this by having a registry entry MEM_LEVEL_WARN under DOORS Cleint->Config and specify suitable value. Significance of this value is - Rational DOORS will start closing all back end open modules when application reaches MEM_LEVEL_CLOSE  mb of memory and even after closing all background modules if memory consumed by Rational DOORS is more than the value specified by this MEM_LEVEL_WARN registry entry then Rational DOORS shows a warning message to user. So it means Rational DOORS is consuming more memory than mentioned warning level by customer. So an ideal value would be 800 to 1600 for a 2 GB Ram machine.

 

MEM_LEVEL_STEP - Its default value is 200 MB and this value is used to step up the MEM_LEVEL_WARN level at run time. A warning will be displayed at run time and at that time you can step up the MEM_LEVEL_WARN level by looking at the system memory. Customer can override this by having a registry entry MEM_LEVEL_STEP under DOORS Client->Config and specify suitable value.

 

Note: This is available from DOORS 9.3.0.7 onwards. A manual interpretation may be needed (after DOORS 9.5) when using these API's (perms) because a warning will be displayed when Rational DOORS touches MEM_LEVEL_WARN level and thus user has to select either to continue or abort. Also there is no much side effect of using these perms while looping through objects but it may affect performance to very negligible extent because we are doing memory checks at regular intervals and trying to close module at regular intervals and customer have to adjust these settings via registry entries so that performance is not effected and also crash does not occur.

Re: Predicting DXL Memory and CPU Usage
VinayN - Mon Oct 21 04:58:04 EDT 2013

Please see my reply below for using memory management perms in Rational DOORS.

Re: Predicting DXL Memory and CPU Usage
llandale - Mon Oct 21 09:24:21 EDT 2013

VinayN - Mon Oct 21 04:57:09 EDT 2013

Usage of memory management perms:

1) initNotDisplayedOpenModules()    -  This is 1st perm which records modules already opened before any operation begins and should be called at start of any looping operation.

2) DisplayMemoryWarning()   - 2nd perm which checks memory usage of application and closes modules opened in back end when application consumes more memory than the prescribed warning level and this should be placed inside a for or while loop so that memory is monitored in each iteration in regular interval.
3) closeNotDisplayedOpenedModules() - 3rd perm which does all cleanup operation at last and closees all modules opened in back end during end of any operation


Usage of these three perms is shown below in the example code and these 3 DXL perms should be used in combination and  when user is looping through all objects in a module with huge data or objects.


 /********************************************/

               Object o = current
               initNotDisplayedOpenModules()    // First perm which records modules opened before any operation
               Module m = current
               int i = 0
               for o in m do
               {
                   if (DisplayMemoryWarning())   //second perm which checks memory usage and closes                        //modules opened during any operation
                   {
                              break
                   }
                   i = o."Absolute Number"
                   gotoObject(i, m)
                   o = next o
               }   
               closeNotDisplayedOpenedModules() // Third perm which does all cleanup operation and tries to close //all modules which were opened during the operation


 /********************************************/


1) initNotDisplayedOpenModules()   is used before the start of the operation
2) DisplayMemoryWarning())   is used during actual operation i.e. with in for or while loop which monitors memory used by application.
3) closeNotDisplayedOpenedModules() is used at the end of the operation.


Rational DOORS DXL developer should use these 3 perms in any custom DXL code where it involves looping of all objects in a big module with huge data and links to other module. This should be used inside a loop which actually loops through all objects to collect data.

 

Customizing these new memory management perms:

 

Memory usage varies from system to system. Some system may have good memory and thus DOORS can use more memory for its operations. Since we cannot fix a value or generalize the maximum memory that can be used by Rational DOORS, we have given some registry values to customize it. This helps Rational DOORS DXL developer to set the system memory that DOORS can use.

 

Default values set in Rational DOORS:

By default there are certain parameters set and these can be overridden by registry entries set under DOORS client registry under config key. Below are the registry string keys with its importance and usage

 

MEM_LEVEL_CLOSE - Its default value is 1000 MB and upon reaching this level, the memory management perm will start closing opened modules that it keeps track of. Customer can override this max value by having a string key registry entry MEM_LEVEL_CLOSE under DOORS Client->Config and specify suitable value. Customer should know what is the maximum MB of memory that his system can allocate to DOORS and give that value under this registry key. For example if a machine can allocate 2 GB of memory to doors.exe without making it crash then value for this registry key would be 1800 or 2000. So they have to decide the value by trial and error method. Higher the value good performance but machine should have such high memory to allocate.


MEM_LEVEL_WARN - Its default value is 800 MB and upon reaching this level, the memory management perm will warn user to either continue or abort the operation to avoid crash. Customer can override this by having a registry entry MEM_LEVEL_WARN under DOORS Cleint->Config and specify suitable value. Significance of this value is - Rational DOORS will start closing all back end open modules when application reaches MEM_LEVEL_CLOSE  mb of memory and even after closing all background modules if memory consumed by Rational DOORS is more than the value specified by this MEM_LEVEL_WARN registry entry then Rational DOORS shows a warning message to user. So it means Rational DOORS is consuming more memory than mentioned warning level by customer. So an ideal value would be 800 to 1600 for a 2 GB Ram machine.

 

MEM_LEVEL_STEP - Its default value is 200 MB and this value is used to step up the MEM_LEVEL_WARN level at run time. A warning will be displayed at run time and at that time you can step up the MEM_LEVEL_WARN level by looking at the system memory. Customer can override this by having a registry entry MEM_LEVEL_STEP under DOORS Client->Config and specify suitable value.

 

Note: This is available from DOORS 9.3.0.7 onwards. A manual interpretation may be needed (after DOORS 9.5) when using these API's (perms) because a warning will be displayed when Rational DOORS touches MEM_LEVEL_WARN level and thus user has to select either to continue or abort. Also there is no much side effect of using these perms while looping through objects but it may affect performance to very negligible extent because we are doing memory checks at regular intervals and trying to close module at regular intervals and customer have to adjust these settings via registry entries so that performance is not effected and also crash does not occur.

Wow.  Turns out about 8 years ago I wrote functions practically identical to these 3.  I arbitrarily decided to measure "number of open modules" and arbitrarily decided "40" was the threshold; and the middle perm would close modules that were opened when 40 of them were open.  My library functions that dealt with "all modules in the folder" would auto-call these memory management functions.  I made a feeble effort to close modules that were not open "recently" and keep modules open that were opened "recently" or "frequently" but I failed at that.

Functions work reasonably well but I knew they could be drastically improved; maybe I'll take a peak at these.

-Louie

Re: Predicting DXL Memory and CPU Usage
ProgrammingRai - Wed Sep 21 08:20:29 EDT 2016

Mathias Mamsch - Fri Oct 18 05:58:47 EDT 2013

Just my two cents: If you are running one script on a large set of modules, how about a parallelization framework? In python for example it is cool, using the multiprocessing library you can do something like this:

def doWork (item):
        # expensive work
        pass

with multiprocessing.pool(5) as pool:  # use 5 parallel processes
       result = pool.map(doWork, [ ... list of items ... ]

The multiprocessing library will take care about starting 5 processes, splitting up the list of items into parts, feeding it to the 5 processes, executing the function doWork on the items and sending the results back to the calling process. I figure something equal can be done in DXL. It will not only speed up your process (due to parallelization -> most operations seem to be CPU bound), but also get rid of memory issues, since you can use MORE memory even on DOORS 8 (because of parallel processes) and memory will get freed by the external processes after completion. You will however require a couple of licenses (at least one more than usual) on parallel processing, but I guess this is something most companies might be willing to take for the runtime of the scripts.

If you are interested in doing something like this together, msg me. However regarding your original question we implemented successfully to measure the DOORS memory allocation using an external tool from DXL and safely stopping the script at a configurable memory barrier. This might also a way to go. When it comes to actually predicting the memory usage, this is kind of unreliable. Depending on the size of data you will encounter next you will waste more or less memory, so you probably cannot say reliably, how many modules you will be able to execute without actually doing it ...

Just my two cents, regards, Mathias
 

Hello Mathias,

 

how does this parallelized work with modules in doors work?

 

Thanks,

Rainer

Re: Predicting DXL Memory and CPU Usage
Mathias Mamsch - Wed Sep 21 09:58:41 EDT 2016

ProgrammingRai - Wed Sep 21 08:20:29 EDT 2016

Hello Mathias,

 

how does this parallelized work with modules in doors work?

 

Thanks,

Rainer

I made a DOORS parallelization framework once (which did not get a lot of response on this forum). The idea of it was, to make a framework, that allows to parallelize DOORS Batch Jobs, passing data (parameters) to each one and collect their results. 

I made this framework as a DXL tutorial, which you can find here (from where you can get in-depth information about how it works): https://github.com/domoran/DXLParallels/blob/master/TUTORIAL.TXT

The nice thing is, that you can have a "self-parallelizing" script, which contains a statement

if (isBatch()) {
   // batch worker code
} else {
   // main script code, e.g. GUI, etc.
}


When launching the script from the menu, it will execute the main script code, which can call itself to parallelize its execution (like a fork). 

On the github project here is an example for an SQLite Exporter using the parallels framework. This exporter will run as many parallel exports for the data of a DOORS module at the same time. The only problem I am aware of, is, that when you launch many DOORS batch jobs at exactly the same time over the shell, then a few of them will get failed logins (probably due to the server locking the user directory during login).

If you are interested I can get back to the project to solve this issue. 

 

By the way, the original post for the parallelization framework is here: 

https://www.ibm.com/developerworks/community/forums/html/topic?id=fddb2dcd-7f7a-4c92-81d3-a606fd7958a7&ps=25

So In case of any questions regarding the framework or such, you can also go to that post. 

Regards, Mathias